
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>班级留言板</title>

    <!-- Bootstrap core CSS -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="../../assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="jumbotron.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="../../assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .form-signin{
            width: 500px;
            margin: 100px auto 0;
        }
    </style>
</head>

<body>

<% include header.ejs%>

<div class="container">

    <form class="form-signin">
        <h2 class="form-signin-heading">请登录</h2>
        <p>用户名</p>
        <label for="inputEmail" class="sr-only"></label>
        <input type="text" id="name" name="name" class="form-control" placeholder="请输入您的用户名" required autofocus>
        <p>密码</p>
        <label for="inputPassword" class="sr-only"></label>
        <input type="password" id="pwd" name="pwd" class="form-control" placeholder="请输入您的密码" required><br>
        <button class="btn btn-lg btn-primary btn-block" type="button" id="btn">登录</button>
    </form>

</div> <!-- /container -->


<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
<script src="/js/jquery.min.js"></script>
</body>
<script>
    $("#btn").on("click", function (e) {
        $.ajax({
            url:"/doLogin",
            type:"post",
            data:{
                "username":$("#name").val(),
                "pwd":$("#pwd").val()
            },
            success:function(result){
                console.log(result);
                if(result=="1"){
                    alert("登录成功 点击确定跳转到首页");
                    window.location.href="/";
                }else if(result=="-2"){
                    alert("密码错误");
                }
            }
        })
    });
</script>
</html>